<template>
  <div>
    <el-input v-model="con" type="textarea" :rows="8" placeholder="请填写取消农事原因，便于负责人知晓以及对计划优化" />
    <div style="margin: 20px 0 0 0;">
      <el-button size="small" type="primary" @click="confirm">确 定</el-button>
      <el-button size="small" @click="close">取 消</el-button>
    </div>
  </div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { cancelPlantLineItem } from '@/api/plant'
import { message } from '@/utils/element'
const props = defineProps({
  options: {
    type: Object,
    default: {}
  }
})

const emit = defineEmits(['close'])

const con = ref('')

onMounted(() => {
  console.log(' props.options', props.options)
})

const confirm = async() => {
  if (!con.value) {
    return message('请填写取消农事原因！', 3)
  }
  const res = await cancelPlantLineItem([props.options.plantingPlanTaskId])
  console.log(res, '--------33')
  if (res.code === 0 || res.success) {
    props.options.taskStatus = 'CANCEL' // 状态设为取消状态
    props.options.taskStatusMeaning = '已取消'
    props.options.reason = con.value
    props.options.deleteFlag = true
    close()
  } else {
    message(res.message, 3)
  }
}

const close = () => {
  emit('close')
}
</script>
